package com.ctrip.payment.test.ngtest;

import com.ctrip.payment.test.ngtest.Bean.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;

// TODO DataProvider 注解不能和 Parameters 注解一起使用
public class NGDataProvider {

    private static final Logger logger = LoggerFactory.getLogger(NGDataProvider.class);

    @DataProvider(name = "getUserById")
    public static Object[][] getUserById() throws Exception {
        String uid = "11255";
        logger.info("getUserById uid = {}, thread name ={}", uid, Thread.currentThread().getName());
        // 模拟从数据库中获取用户 uid
        TimeUnit.MILLISECONDS.sleep(1000);
        return new Object[][]{{ new User(uid, "testUser") }};
    }


    @Test(dataProvider = "getUserById")
    public void testUser(User user) {
        logger.info("user info = {}, thread name ={}", user.toString(), Thread.currentThread().getName());
    }


}
